<%@ page import="aiball.Player"%>
<!doctype html>
<html>
<head>
<meta name="layout" content="main">
<g:set var="entityName"
	value="${message(code: 'player.label', default: 'Player')}" />
<title><g:message code="default.edit.label" args="[entityName]" /></title>

<link rel="stylesheet" href="${resource(dir: 'css/jqui/custom-theme', file: 'jquery-ui-1.8.20.custom.css')}" type="text/css">


<!--link rel="stylesheet" href="/AIBall/js/codemirror/lib/codemirror.css"
	type="text/css" -->
<script
	src="../../static/plugins/jquery-1.7.1/js/jquery/jquery-1.7.1.min.js"
	type="text/javascript"></script>
<script
	src="../../static/plugins/jquery-ui-1.8.15/jquery-ui/js/jquery-ui-1.8.15.custom.min.js"
	type="text/javascript"></script>

<jq:plugin name="form" />


<script src="${resource(dir: 'js/codehighlighter/js/', file: 'codemirror.js')}"
	type="text/javascript"></script>
<!--
<script src="/AIBall/js/codehighlighter/js/codemirror.js"
	type="text/javascript"></script>-->


<script type="text/javascript">

var editor;

function openUpload()
{
	$('#uplform').dialog({
		show: "fade",
		hide: "puff",
		resizable: false,
		minWidth: 430,
		minHeight: 150
		
	});
}

function closeUpload(data)
{
	$('#uplform').dialog('close');
	$('#sourceCode').val(data);
	  editor = CodeMirror.fromTextArea(document.getElementById('sourceCode'), {
		    parserfile: ["tokenizejava.js","parsejava.js"],
		    stylesheet: "../../js/codehighlighter/css/javacolors.css",
		    path: "/js/codehighlighter/js/"
		  });
}

function clearText()
{
editor.toTextArea();
$('#sourceCode').empty();
}

$(document).ready( function() {

  
	  editor = CodeMirror.fromTextArea(document.getElementById('sourceCode'), {
		    lineNumbers: true,
		    parserfile: ["tokenizejava.js","parsejava.js"],
		    stylesheet: "../../js/codehighlighter/css/javacolors.css",
		    path: "/js/codehighlighter/js/"
		  });
 
	 var options2 = { 
		        target:        '#sourceCode',   // target element(s) to be updated with server response 
		        beforeSubmit:  clearText,  // pre-submit callback 
		        success:       closeUpload  // post-submit callback 
		 
		        // other available options: 
		        //url:       url         // override for form's 'action' attribute 
		        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
		        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
		        //clearForm: true        // clear all form fields after successful submit 
		        //resetForm: true        // reset the form after successful submit 
		 
		        // $.ajax options can be used here too, for example: 
		        //timeout:   3000 
		    }; 
	$('form:last').ajaxForm(options2);
	
});

</script>

</head>
<body>
	<a href="#edit-player" class="skip" tabindex="-1"><g:message
			code="default.link.skip.label" default="Skip to content&hellip;" /></a>
	<div class="nav" role="navigation">
		<ul>
			<li><a class="home" href="${createLink(uri: '/')}"><g:message
						code="default.home.label" /></a></li>
			<li><g:link class="list" action="list">
					<g:message code="default.list.label" args="[entityName]" />
				</g:link></li>
			<li><g:link class="create" action="create">
					<g:message code="default.new.label" args="[entityName]" />
				</g:link></li>
		</ul>
	</div>
	<div id="edit-player" class="content scaffold-edit" role="main">
		<h1>
			<g:message code="default.edit.label" args="[entityName]" />
		</h1>
		<g:if test="${flash.message}">
			<div class="message" role="status">
				${flash.message}
			</div>
		</g:if>
		<g:hasErrors bean="${playerInstance}">
			<ul class="errors" role="alert">
				<g:eachError bean="${playerInstance}" var="error">
					<li
						<g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
							error="${error}" /></li>
				</g:eachError>
			</ul>
		</g:hasErrors>
		<g:form method="post">
			<g:hiddenField name="id" value="${playerInstance?.id}" />
			<g:hiddenField name="version" value="${playerInstance?.version}" />
			<fieldset class="form">
				<g:render template="form" />
			</fieldset>
			<fieldset class="buttons">
				<g:actionSubmit class="save" action="update"
					value="${message(code: 'default.button.update.label', default: 'Update')}" />
				<input class="upload" type="button" value="upload" onClick="openUpload()">
			</fieldset>

		</g:form>


	

		<div id="uplform" style="display: none;">
			<g:uploadForm action="upload" method="post">
				<label for="payload">File:</label>
				<input type="file" id="payload" name="payload" />
				<br>
				<input type="submit"
					value="Upload" />
			</g:uploadForm>
		</div>

	</div>
	
	
</body>
</html>
